Open
Conversation
17cf4dc to
319d5b1
Compare
jonathanlab
approved these changes
Apr 20, 2026
319d5b1 to
065a0f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

TLDR
Adds a file enrichment feature that annotates PostHog-related code with live metadata (event volume, flag rollout/staleness, experiment links) as the agent reads files.
Problem
When the agent reads source files containing PostHog SDK calls, it has no awareness of the current state of those flags or events in production. This means the agent lacks important product context — such as whether a flag is rolled out, how much volume an event has, or whether an event is verified — that would help it make better recommendations.
Changes
@posthog/enricherpackage dependency in the agent, with aFileEnrichmentDeps/Enrichmentabstraction inpackages/agent/src/enrichment/file-enricher.tsthat wrapsPostHogEnricherand exposes anenrichFileForAgentfunctionPostToolUsehook (createReadEnrichmentHook) interceptsReadtool responses, strips line numbers, runs enrichment, and returnsadditionalContextto the model alongside writing enriched content to anEnrichedReadCachekeyed bytool_use_id; the cache is consumed intoolUpdateFromToolResultso the UI displays the annotated versionreadTextFileon theCodexClient, replacing the file content before it reaches codex-acptoInlineComments()method onEnrichedResultthat appends PostHog annotations as inline comments on the same source line (rather than inserting new lines above), and a correspondingformatInlineCommentsfunction in the comment formatterenrichFromApiare now tolerated viaPromise.allSettledrather than rejecting, returning partial/empty enrichment instead{name:Type}) andINTERVALwith a placeholder were rejected;daysBackis now inlined directly into the query stringposthogconfig is present and can be disabled viaenricher: { enabled: false }inAgentConfigParserManagernow checks multiple candidate paths to support packaged Electron app layouts; theforge.config.tsasar unpack glob and a newcopyEnricherGrammarsVite plugin ensure grammars are available at both dev and packaged runtime paths@posthog/enricherenrichFileForAgent,createReadEnrichmentHook, andcreateCodexClient.readTextFile